package com.weizhu.swufer.core.entity;

import com.weizhu.swufer.core.rpc.RpcRequest;

public class InvokeParam {

    private RpcRequest rpcRequest;

    private String targetAddress;

    private boolean async;

    private int tryTimes;

    public Object getAttachment(String key){
        if (rpcRequest == null || rpcRequest.getContextParameters() == null){
            return null;
        }
        return rpcRequest.getContextParameters().get(key);
    }

    public int getTryTimes() {
        return tryTimes;
    }

    public void setTryTimes(int tryTimes) {
        this.tryTimes = tryTimes;
    }

    public RpcRequest getRpcRequest() {
        return rpcRequest;
    }

    public void setRpcRequest(RpcRequest rpcRequest) {
        this.rpcRequest = rpcRequest;
    }

    public String getTargetAddress() {
        return targetAddress;
    }

    public void setTargetAddress(String targetAddress) {
        this.targetAddress = targetAddress;
    }

    public void setAsync(boolean async) {
        this.async = async;
    }

    public boolean isAsync() {
        return async;
    }

    public String getServiceMethodName(){
        return rpcRequest.getInterfaceName() + "." + rpcRequest.getMethodName();
    }
}
